Skip to content

Song#1

Open
SongGwanSeok wants to merge 3 commits intomainfrom
song
Open

Song#1
SongGwanSeok wants to merge 3 commits intomainfrom
song

Conversation

@SongGwanSeok
Copy link
Copy Markdown
Member

No description provided.


private int findStrike(List<Integer> input) {
return (int) IntStream.range(0, 3)
.filter(i -> answer.get(i).equals(input.get(i)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

왜 equals 에요??


private int findBall(List<Integer> input) {
return (int) IntStream.range(0, 3)
.filter(i -> !answer.get(i).equals(input.get(i)) && answer.contains(input.get(i)))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

조건이 읽기 힘든 것 같아요. 다른 방향은 없을까요?

public static List<Integer> generate(){
List<Integer> threeDigitNumber = new ArrayList<>();
while (threeDigitNumber.size() < 3) {
int randomNumber = Randoms.pickNumberInRange(startRange, endRange);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

랜덤 넘버를 테스트 할 수도 있나요?

Comment thread src/main/java/baseball/domain/Computer.java
Comment on lines +8 to +35
@Test
@DisplayName("입력과 정답을 받아 스트라이크 볼의 개수를 가진다.")
void generate() {
int strike = 1;
int ball = 1;

Assertions.assertDoesNotThrow(() ->
new ComparisonResult(strike, ball));

}

@Test
@DisplayName("3스트라이크일 때 true를 반환한다.")
void ThreeStrikeTrue() {
int strike = 3;
int ball = 0;
ComparisonResult result = new ComparisonResult(strike, ball);
Assertions.assertEquals(result.isThreeStrike(), true);
}

@Test
@DisplayName("3스트라이크가 아니면 false를 반환한다.")
void ThreeStrikeFalse() {
int strike = 2;
int ball = 1;
ComparisonResult result = new ComparisonResult(strike, ball);
Assertions.assertEquals(result.isThreeStrike(), false);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이런 테스트도 필요할까요?

List<Integer> threeDigitNumber = new ArrayList<>();
while (threeDigitNumber.size() < 3) {
int randomNumber = Randoms.pickNumberInRange(startRange, endRange);
if (!threeDigitNumber.contains(randomNumber)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

뎁스가,,,2이다,,

}

private void isNotThreeDigitNumber(String input) {
if (!Pattern.matches(threeDigitPattern, input)) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 검증은 뷰의 책임이 맞나요?

void compare2Ball1Strike() throws Exception {
List<Integer> input = List.of(1, 3, 2);

ComparisonResult result = computer.compare(input);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가장 작은 단위의 단위테스트인가요?


public class InputNumberGenerator {

public static List<Integer> generate(String input) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static은 언제 사용하나요?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

주어진 코드는 정답일까요?


@Override
public String toString() {
StringBuilder stringBuilder = new StringBuilder();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringBuilder의 장점은 무엇일까요?


public record ComparisonResult(int strike, int ball) {

public Boolean isThreeStrike() {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

매직넘버를 사용하는 이유는 뭘까요?


public static List<Integer> generate(){
List<Integer> threeDigitNumber = new ArrayList<>();
while (threeDigitNumber.size() < 3) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3은 매직넘버가 아닐까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants